﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using chaoshi.model;
using System.Data.SqlClient;

namespace chaoshi.DAL
{
    public class DALUser
    {
        public Modelsevers userlogin(string name,string pass)
        {
            string sql = string.Format(@"select * from AdminInfo where AdminName = '{0}' and AdminPass = '{1}'", name, pass);
            SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=chaoshidb;User ID=sa;Password=123");
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataReader dr = cmd.ExecuteReader();
            Modelsevers Admin = null;
            while (dr.Read())
            {
                Admin = new Modelsevers();
                Admin.AdminId = Convert.ToInt32(dr["AdminId"]);
                Admin.AdminName = dr["AdminName"].ToString();
                Admin.AdminPass = dr["AdminPass"].ToString();
                Admin.Adminyuangong = Convert.ToInt32(dr["Adminyuangong"]);
                Admin.AdminStatus = Convert.ToInt32(dr["AdminStatus"]);
            }
            dr.Close();
            conn.Close();
            return Admin;
        }
    }
}
